export default {
    methods: {
        // source 来源。1：住院医生站，2：门诊医生站
        getEstimateList(source, patientId) {
            const estimateList = []
            for (let i = 1; i <= 9; i++) {
                let localData = localStorage.getItem(`estimate_${source}_${patientId}_${i}`)
                if (localData) {
                    estimateList.push(JSON.parse(localData))
                }
            }
            return estimateList
        },
        clearLocalEstimate(source, patientId) {
            for (let i = 1; i <= 9; i++) {
                localStorage.getItem(`estimate_${source}_${patientId}_${i}`) && localStorage.removeItem(`estimate_${source}_${patientId}_${i}`)
            }
        },
        getEstimate(source, patientId, estimateId) {
            let estimateText = localStorage.getItem(`estimate_${source}_${patientId}_${estimateId}`)
            if (estimateText) {
                return JSON.parse(estimateText)
            } else {
                return null
            }
        },
        getAssessInfoByEstimate(estimate) {
            if (estimate) {
                let localAssessInfo = {}
                estimate.keyList.forEach(item => {
                    localAssessInfo[item.key] = JSON.parse(item.value)
                })
                return localAssessInfo
            } else {
                return null
            }
        }
    }
}